let main = document.querySelector('.main');
function cinemas(id){
    pAjax({
        url:`../json/cinemas-${id}.json`
    }).then(function(res){
        res = JSON.parse(res).data.cinemas
        yingyuan(res)
        // let box2s = document.querySelectorAll('.box2');
        // lazyload(box2s)
        // main.onscroll = function(){
        //     lazyload(box2s);
        // }      
    })
    
    function yingyuan(res){
        res.forEach((item,index) => {
            main.innerHTML += `<div class="box2">
            <p class="p1"><span>${item.nm}</span><span>${item.price}元起</span></p>
            <p class="p2"><span>${item.addr}</span><span>500m</span></p>
            <p class="p3"><span>退</span><span>退</span><span>改签</span><span>小吃</span></p>
            <p class="p4"><span>惠</span><span>${item.promotion.platformActivityTag}</span></p>
        </div>
         <hr/>`
        });
    }  
}
cinemas(1);
cinemas(2);
cinemas(3);
cinemas(4);
cinemas(5);
cinemas(6);
cinemas(7);

 // 懒加载
function lazyload(box2s){
    let h = window.innerHeight;
    let s = main.scrollTop
    for(let i=0;i<box2s.length;i++){
        if ((h+s)>box2s[i].offsetTop){
            setTimeout(function(){
                // cinemas(2)
            },1000)
        }
    }
}
